package org.linlinjava.litemall.admin.controller;

import org.linlinjava.litemall.admin.beans.annotation.LogAnno;
import org.linlinjava.litemall.admin.beans.dto.ShopProxyRefundDto;
import org.linlinjava.litemall.admin.beans.dto.ShopRefundDto;
import org.linlinjava.litemall.admin.service.AdminRefundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 管理退款控制器
 *
 * @author yliyun
 * @date 2022/09/14
 */
@RestController
@RequestMapping("/admin/refund")
@Validated
public class AdminRefundController {

    /**
     * 管理退款服务
     */
    @Autowired
    private AdminRefundService adminRefundService;

    /**
     * 统计数据
     * 退款统计查询
     *
     * @param startTime 开始时间
     * @param endTime   结束时间
     * @param regionId  区域id
     * @param page      页面
     * @param limit     限制
     * @return {@link Object}
     */
    @GetMapping("/statistics")
    @LogAnno
    public Object statistics(@RequestParam String startTime, @RequestParam String endTime, Integer regionId,
    		@RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer limit) {
        return adminRefundService.statistics(startTime, endTime, regionId, page, limit);
    }

    /**
     * 总统计
     * 汇总统计
     *
     * @param startTime 开始时间
     * @param endTime   结束时间
     * @param regionId  区域id
     * @return {@link Object}
     */
    @GetMapping("/total_statistics")
    @LogAnno
    public Object totalStatistics(@RequestParam String startTime, @RequestParam String endTime, Integer regionId) {
    	return adminRefundService.totalStatistics(startTime, endTime, regionId);
    }

    /**
     * 代理数据
     * 退款统计查询
     *
     * @param startTime 开始时间
     * @param endTime   结束时间
     * @param regionId  区域id
     * @param page      页面
     * @param limit     限制
     * @return {@link Object}
     */
    @GetMapping("/proxy_statistics")
    @LogAnno
    public Object proxyStatistics(String startTime, String endTime, Integer regionId,
    		@RequestParam(defaultValue = "1") Integer page,
    		@RequestParam(defaultValue = "10") Integer limit) {
    	return adminRefundService.proxyStatistics(startTime, endTime, regionId, page, limit);
    }

    /**
     * 代理退款汇总统计
     *
     * @param startTime 开始时间
     * @param endTime   结束时间
     * @param regionId  区域id
     * @return {@link Object}
     */
    @GetMapping("/proxy_total_statistics")
    @LogAnno
    public Object proxyTotalStatistics(@RequestParam String startTime, @RequestParam String endTime, Integer regionId) {
    	return adminRefundService.proxyTotalStatistics(startTime, endTime, regionId);
    }

    /**
     * 商店退款名单
     * 门店退款列表查询
     *
     * @param shopRefundDto 商店退款dto
     * @param page          页面
     * @param limit         限制
     * @return {@link Object}
     */
    @GetMapping("/shop_refund_list")
    @LogAnno
    public Object shopRefundList(@Validated ShopRefundDto shopRefundDto,
    		@RequestParam(defaultValue = "1") Integer page,
    		@RequestParam(defaultValue = "10") Integer limit) {
    	return adminRefundService.shopRefundList(shopRefundDto, page, limit);
    }

    /**
     * 店总统计
     * 门店退款汇总统计
     *
     * @param shopRefundDto 商店退款dto
     * @return {@link Object}
     */
    @GetMapping("/total_shop_statistics")
    @LogAnno
    public Object totalShopStatistic(@Validated ShopRefundDto shopRefundDto) {
    	return adminRefundService.totalShopStatistic(shopRefundDto);
    }

    /**
     * 店代理退款名单
     * 门店代理退款列表查询
     *
     * @param shopProxyRefundDto 店代理退款dto
     * @param page               页面
     * @param limit              限制
     * @return {@link Object}
     */
    @GetMapping("/shop_proxy_refund_list")
    @LogAnno
    public Object shopProxyRefundList(@Validated ShopProxyRefundDto shopProxyRefundDto,
    		@RequestParam(defaultValue = "1") Integer page,
    		@RequestParam(defaultValue = "10") Integer limit) {
    	return adminRefundService.shopProxyRefundList(shopProxyRefundDto, page, limit);
    }

    /**
     * 店代理总统计
     * 门店代理退款汇总统计
     *
     * @param shopProxyRefundDto 店代理退款dto
     * @return {@link Object}
     */
    @GetMapping("/total_shop_proxy_statistics")
    @LogAnno
    public Object totalShopProxyStatistic(@Validated ShopProxyRefundDto shopProxyRefundDto) {
    	return adminRefundService.totalShopProxyStatistic(shopProxyRefundDto);
    }

    /**
     * 细节
     * 退款详情
     *
     * @param id id
     * @return {@link Object}
     */
    @GetMapping("/detail")
    @LogAnno
    public Object detail(@RequestParam Integer id) {
    	return adminRefundService.detail(id);
    }
    
}
